package com.sg.service.biz.app.impl;

import cn.hutool.core.bean.BeanUtil;
import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.app.req.ImplementPicMultipleSetDataEntryComReqDto;
import com.sg.dto.biz.app.req.ImplementPicMultipleSetDataEntryReqDto;
import com.sg.dto.biz.app.res.ImplementPicMultipleSetDataEntryComRespDto;
import com.sg.dto.biz.app.res.ImplementPicMultipleSetDataEntryRespDto;
import com.sg.service.base.app.MOmsTspeCycleStageDataService;
import com.wicket.okrcomponent.integration.DataSetSingleEntryService;
import com.wicket.okrcomponent.integration.InterfaceModeService;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.stream.Collectors;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class DataSetSingleEntryServiceImpl
        implements com.wicket.okrapp.biz.service.DataSetSingleEntryService {

    @Resource
    private RedisUtil redisUtil;
    //@Resource
    //private MCustomFieldsService mCustomFieldsService;
    @Resource
    private NbDataSetSingleEntry nbDataSetSingleEntry;
    @Resource
    private InterfaceModeService interfaceModeService;
    @Resource
    private MOmsTspeCycleStageDataService mOmsTspeCycleStageDataService;
    @Resource
    private DataSetSingleEntryService fwCompDataSetSingleEntryClient;

    /**
     * D3执行图片多条转数据集(公共)[8079]
     * gen by moon at 12/5/2023, 12:41:19 AM
     */
    @Trace(operationName = "D3执行图片多条转数据集(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ImplementPicMultipleSetDataEntryComRespDto implementPicMultipleSetDataEntryCom(ImplementPicMultipleSetDataEntryComReqDto reqDto) {


        ImplementPicMultipleSetDataEntryRespDto objectToDataRes_1 = null;
//步骤0: M3执行图片多条转数据集 - implementPicMultipleSetDataEntry
        //ModelCode: objectToData
        ImplementPicMultipleSetDataEntryRespDto objectToDataRes = null;
        ImplementPicMultipleSetDataEntryReqDto objectToDataReq = new ImplementPicMultipleSetDataEntryReqDto();
        if (reqDto != null) {
            objectToDataReq.setPicMultipleSetDataEntryList(reqDto.getPicMultipleSetDataEntryList().stream().map(item -> BeanUtil.toBean(item, PicMultipleSetDataEntryDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:1379330_1
        }

        /*M3执行图片多条转数据集[2801]  用于周期阶段资料内容中查询的多个图片信息，数据库中一个字段中的信息将转换到多张图片信息的地址（数据集）供前端展示 */

        objectToDataRes = nbDataSetSingleEntry.implementPicMultipleSetDataEntry(objectToDataReq);


        objectToDataRes_1 = objectToDataRes;

        ImplementPicMultipleSetDataEntryComRespDto retData = new ImplementPicMultipleSetDataEntryComRespDto();
        if (objectToDataRes_1 != null) {
            retData.setPicMultipleSetDataEntryList(objectToDataRes_1.getPicMultipleSetDataEntryList().stream().map(item -> BeanUtil.toBean(item, PicMultipleSetDataEntryDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:1379333_1
        }


        return retData;
    }
    //
}
